package waf

import (
	"time"
)

// RuleType 规则类型
type RuleType string

const (
	SQLInjection RuleType = "sql_injection"
	XSS          RuleType = "xss"
	IPBlacklist  RuleType = "ip_blacklist"
	IPWhitelist  RuleType = "ip_whitelist"
)

// Rule 安全规则
type Rule struct {
	ID          int64     `json:"id" gorm:"primaryKey"`
	Type        RuleType  `json:"type"`        // 规则类型
	Pattern     string    `json:"pattern"`     // 规则模式
	Description string    `json:"description"` // 规则描述
	Status      int       `json:"status"`      // 规则状态：1-启用，0-禁用
	CreatedAt   time.Time `json:"created_at"`
	UpdatedAt   time.Time `json:"updated_at"`
}

// TableName 指定表名
func (Rule) TableName() string {
	return "waf_rule"
}
